using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using Volo.Abp.Identity;
using Volo.Abp.SettingManagement;
using Volo.Abp.AuditLogging;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.FeatureManagement;
using Volo.Abp.OpenIddict;
using Matrix.Configuration;
using UserManagementService.Users;
using UserManagementService.Organizations;
using UserManagementService.Permissions;

namespace UserManagementService;

[DependsOn(
    typeof(AbpIdentityDomainModule),
    typeof(AbpSettingManagementDomainModule),
    typeof(AbpAuditLoggingDomainModule),
    typeof(AbpBackgroundJobsDomainModule),
    typeof(AbpFeatureManagementDomainModule),
    typeof(AbpOpenIddictDomainModule),
    typeof(MatrixConfigurationDomainModule),
    typeof(UserManagementServiceDomainSharedModule)
)]
public class UserManagementServiceDomainModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        // 注册领域服务
        context.Services.AddTransient<IUserPermissionService, UserPermissionService>();
        context.Services.AddTransient<IOrganizationManagementService, OrganizationManagementService>();

        // 配置用户管理选项
        Configure<UserManagementOptions>(options =>
        {
            options.EnableOrganizationManagement = true;
            options.EnableCustomPermissions = true;
            options.EnableUserImportExport = true;
            options.EnableUserImpersonation = true;
        });
    }
}